package com.ruoyi.project.product.url.service;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.product.url.domain.Url;
import com.ruoyi.project.product.url.mapper.UrlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UrlServiceImpl implements IUrlService {

    @Autowired
    private UrlMapper urlMapper;

    /**
     * 系列查询
     * @param url
     * @return
     */
    @Override
    public List<Url> selectUrlList(Url url) {
        return urlMapper.selectUrlList(url);
    }

    /**
     * 系列批量删除操作
     * @param ids
     * @return
     * @throws Exception
     */
    @Override
    public int deleteUrlByIds(String ids) throws Exception {
        return urlMapper.deleteUrlByIds(Convert.toLongArray(ids));
    }

    /**
     * 根据id查询图片
     * @param urlId
     * @return
     */
    @Override
    public Url selectUrlById(Integer urlId) {
        return urlMapper.selectUrlById(urlId);
    }

    /**
     * 图片添加
     * @param newFileName
     * @return
     */
    @Override
    public int insertUrl(String newFileName) {
        return urlMapper.insertUrl("/img/" + newFileName);
    }

}
